# konrad.smolinski@gmail.com
# date:		   23/11/2010
# last update: 1/12/2010
#
# info:
#	we assume:
#	 Y is binary: Y in {0,1}
#	 X has K-points of support: {x_1,...,x_K}
# 	 Z has R-points of support: {z_1,...,z_R}
# 	 U = (U1,U2)
#
# dependencies:
# ---------------------------------------------------------------------------------------
# normalCopula() : copula function
rcNormalCopula <- function(u=c(0.5,0.5),mu=c(0,0),sig=cbind(c(1,0),c(0,1)) ){
	x <- qnorm(u[1],mean=mu[1],sd=sqrt(sig[1,1]))
	y <- qnorm(u[2],mean=mu[2],sd=sqrt(sig[2,2]))
	rho <- sig[1,2]/sqrt(sig[1,1]*sig[2,2])
	mdnorm <- exp(-(x^2+y^2-2*rho*x*y)/(2*(1-rho^2)) )/(2*pi*sqrt(1-rho^2))
	res <- mdnorm/(dnorm(x)*dnorm(y))
return(res)
}
# ---------------------------------------------------------------------------------------
